using System.Data.Entity.Migrations;
namespace RealtReview.DataAccess.Migrations
{
    public partial class removeAdvertisments : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.Advertisment", "ApartmentId", "dbo.Apartment");
            DropForeignKey("dbo.Comment", "Advertisment_Id", "dbo.Advertisment");
            DropForeignKey("dbo.Advertisment", "User_Id", "dbo.ApplicationUsers");
            DropIndex("dbo.Advertisment", new[] { "ApartmentId" });
            DropIndex("dbo.Advertisment", new[] { "User_Id" });
            DropIndex("dbo.Comment", new[] { "Advertisment_Id" });
            DropColumn("dbo.Comment", "Advertisment_Id");
            DropTable("dbo.Advertisment");
        }
        
        public override void Down()
        {
            CreateTable(
                "dbo.Advertisment",
                c => new
                    {
                        Id = c.Guid(nullable: false, identity: true),
                        UserId = c.Guid(nullable: false),
                        ApartmentId = c.Guid(nullable: false),
                        DateCreated = c.DateTime(nullable: false),
                        User_Id = c.String(maxLength: 128),
                    })
                .PrimaryKey(t => t.Id);
            
            AddColumn("dbo.Comment", "Advertisment_Id", c => c.Guid());
            CreateIndex("dbo.Comment", "Advertisment_Id");
            CreateIndex("dbo.Advertisment", "User_Id");
            CreateIndex("dbo.Advertisment", "ApartmentId");
            AddForeignKey("dbo.Advertisment", "User_Id", "dbo.ApplicationUsers", "Id");
            AddForeignKey("dbo.Comment", "Advertisment_Id", "dbo.Advertisment", "Id");
            AddForeignKey("dbo.Advertisment", "ApartmentId", "dbo.Apartment", "Id", cascadeDelete: true);
        }
    }
}
